From: Florian Müllner Date: Thu, 5 Mar 2020 16:44:27 +0000 (+0100) Subject: extensionPrefs: Use imports.package.start() X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~751^2^2~122 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e572d5d08c8c82818aeba25eda1f327e1a85fef1;p=gnome-shell.git extensionPrefs: Use imports.package.start() We want to make the extensions app code more self-contained to make it easier to build separately, and ultimately make it available on flathub. One complication we are facing is that it is currently all over the source tree: - js/extensionPrefs for the main code - src for the launcher process - data for .desktop file and icons Switching from a C launcher to the imports.package module allows us to consolidate the first two, and will also take care of the annoying setup bits (defining JS search path, extending GI lookup, loading resources). https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081 --- diff --git a/js/extensionPrefs/gnome-shell-extension-prefs.in b/js/extensionPrefs/gnome-shell-extension-prefs.in new file mode 100644 index 000000000..dc6d62760 --- /dev/null +++ b/js/extensionPrefs/gnome-shell-extension-prefs.in @@ -0,0 +1,2 @@ +#!/bin/sh +@gjs@ @pkgdatadir@/@app_id@ "$@" diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js index 02e68c76d..936598c05 100644 --- a/js/extensionPrefs/main.js +++ b/js/extensionPrefs/main.js @@ -2,13 +2,13 @@ imports.gi.versions.Gdk = '3.0'; imports.gi.versions.Gtk = '3.0'; +imports.package.initFormat(); + const Gettext = imports.gettext; const { Gdk, GLib, Gio, GObject, Gtk } = imports.gi; -const Format = imports.format; const _ = Gettext.gettext; -const Config = imports.misc.config; const ExtensionUtils = imports.misc.extensionUtils; const { loadInterfaceXML } = imports.misc.fileUtils; @@ -46,7 +46,7 @@ class Application extends Gtk.Application { super.vfunc_startup(); let provider = new Gtk.CssProvider(); - let uri = 'resource:///org/gnome/shell/css/application.css'; + let uri = 'resource:///org/gnome/Extensions/css/application.css'; try { provider.load_from_file(Gio.File.new_for_uri(uri)); } catch (e) { @@ -61,11 +61,9 @@ class Application extends Gtk.Application { } vfunc_command_line(commandLine) { - let args = commandLine.get_arguments(); - - if (args.length) { - let uuid = args[0]; + let [prgName_, uuid] = commandLine.get_arguments(); + if (uuid) { // Strip off "extension:///" prefix which fakes a URI, if it exists uuid = stripPrefix(uuid, 'extension:///'); @@ -79,7 +77,7 @@ class Application extends Gtk.Application { var ExtensionsWindow = GObject.registerClass({ GTypeName: 'ExtensionsWindow', - Template: 'resource:///org/gnome/shell/ui/extensions-window.ui', + Template: 'resource:///org/gnome/Extensions/ui/extensions-window.ui', InternalChildren: [ 'userList', 'systemList', @@ -219,7 +217,7 @@ var ExtensionsWindow = GObject.registerClass({ comments: _('Manage your GNOME Extensions'), license_type: Gtk.License.GPL_2_0, logo_icon_name: 'org.gnome.Extensions', - version: Config.PACKAGE_VERSION, + version: imports.package.version, transient_for: this, modal: true, @@ -571,7 +569,7 @@ var Expander = GObject.registerClass({ var ExtensionRow = GObject.registerClass({ GTypeName: 'ExtensionRow', - Template: 'resource:///org/gnome/shell/ui/extension-row.ui', + Template: 'resource:///org/gnome/Extensions/ui/extension-row.ui', InternalChildren: [ 'nameLabel', 'descriptionLabel', @@ -751,8 +749,6 @@ function initEnvironment() { userdatadir: GLib.build_filenamev([GLib.get_user_data_dir(), 'gnome-shell']), }; - - String.prototype.format = Format.format; } function main(argv) { diff --git a/js/extensionPrefs/meson.build b/js/extensionPrefs/meson.build new file mode 100644 index 000000000..97da99714 --- /dev/null +++ b/js/extensionPrefs/meson.build @@ -0,0 +1,46 @@ +app_id = 'org.gnome.Extensions' +prgname = 'gnome-shell-extension-prefs' + +launcherconf = configuration_data() +launcherconf.set('app_id', app_id) +launcherconf.set('PACKAGE_NAME', meson.project_name()) +launcherconf.set('PACKAGE_VERSION', meson.project_version()) +launcherconf.set('prefix', prefix) +launcherconf.set('libdir', libdir) +launcherconf.set('pkgdatadir', pkgdatadir) +launcherconf.set('gjs', gjs.path()) + +configure_file( + input: prgname + '.in', + output: prgname, + configuration: launcherconf, + install_dir: bindir, + install_mode: 'rwxr-xr-x', +) + +configure_file( + input: app_id + '.in', + output: app_id, + configuration: launcherconf, + install_dir: pkgdatadir, +) + +config_dir = '@0@/..'.format(meson.current_build_dir()) + +gnome.compile_resources( + app_id + '.src', + app_id + '.src.gresource.xml', + dependencies: [config_js], + source_dir: ['.', '..', config_dir], + gresource_bundle: true, + install: true, + install_dir: pkgdatadir +) + +gnome.compile_resources( + app_id + '.data', + app_id + '.data.gresource.xml', + gresource_bundle: true, + install: true, + install_dir: pkgdatadir +) diff --git a/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml b/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml new file mode 100644 index 000000000..f6fc66b72 --- /dev/null +++ b/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml @@ -0,0 +1,9 @@ + + + + css/application.css + + ui/extension-row.ui + ui/extensions-window.ui + + diff --git a/js/extensionPrefs/org.gnome.Extensions.in b/js/extensionPrefs/org.gnome.Extensions.in new file mode 100644 index 000000000..da7ab2512 --- /dev/null +++ b/js/extensionPrefs/org.gnome.Extensions.in @@ -0,0 +1,6 @@ +imports.package.start({ + name: '@PACKAGE_NAME@', + version: '@PACKAGE_VERSION@', + prefix: '@prefix@', + libdir: '@libdir@', +}); diff --git a/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml b/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml new file mode 100644 index 000000000..9b0fa09ac --- /dev/null +++ b/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml @@ -0,0 +1,10 @@ + + + + main.js + + misc/config.js + misc/extensionUtils.js + misc/fileUtils.js + + diff --git a/js/meson.build b/js/meson.build index 9a230d65d..8b131d8dd 100644 --- a/js/meson.build +++ b/js/meson.build @@ -1,5 +1,6 @@ subdir('misc') subdir('dbusServices') +subdir('extensionPrefs') js_resources = gnome.compile_resources( 'js-resources', 'js-resources.gresource.xml', @@ -14,10 +15,3 @@ portal_resources = gnome.compile_resources( c_name: 'portal_js_resources', dependencies: [config_js] ) - -prefs_resources = gnome.compile_resources( - 'prefs-resources', 'prefs-resources.gresource.xml', - source_dir: ['.', meson.current_build_dir()], - c_name: 'prefs_js_resources', - dependencies: [config_js] -) diff --git a/js/prefs-resources.gresource.xml b/js/prefs-resources.gresource.xml deleted file mode 100644 index 548a46a3e..000000000 --- a/js/prefs-resources.gresource.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - extensionPrefs/main.js - - misc/config.js - misc/extensionUtils.js - misc/fileUtils.js - - extensionPrefs/css/application.css - - extensionPrefs/ui/extension-row.ui - extensionPrefs/ui/extensions-window.ui - - diff --git a/src/gnome-shell-extension-prefs.c b/src/gnome-shell-extension-prefs.c deleted file mode 100644 index 7ff728e1e..000000000 --- a/src/gnome-shell-extension-prefs.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ - -#include "config.h" - -#include -#include - -int -main (int argc, char *argv[]) -{ - const char *search_path[] = { "resource:///org/gnome/shell", NULL }; - GError *error = NULL; - GjsContext *context; - int status; - - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - context = g_object_new (GJS_TYPE_CONTEXT, - "search-path", search_path, - NULL); - - if (!gjs_context_define_string_array(context, "ARGV", - argc - 1, (const char**)argv + 1, - &error)) - { - g_message("Failed to defined ARGV: %s", error->message); - g_error_free (error); - g_object_unref (context); - - return 1; - } - - if (!gjs_context_eval (context, - "const Main = imports.extensionPrefs.main; Main.main(ARGV);", - -1, - "
", - &status, - &error)) - { - g_message ("Execution of main.js threw exception: %s", error->message); - g_error_free (error); - g_object_unref (context); - - return status; - } - - g_object_unref (context); - return 0; -} diff --git a/src/meson.build b/src/meson.build index 8e18e3080..05bdb9bea 100644 --- a/src/meson.build +++ b/src/meson.build @@ -249,15 +249,6 @@ executable('gnome-shell', 'main.c', install: true ) -executable('gnome-shell-extension-prefs', - 'gnome-shell-extension-prefs.c', prefs_resources, - c_args: tools_cflags, - dependencies: tools_deps, - include_directories: [conf_inc], - install: true -) - - if have_networkmanager executable('gnome-shell-portal-helper', 'gnome-shell-portal-helper.c', portal_resources,